<?php

namespace backend\services\echarts;

use backend\extensions\ApiBaseService;

/**
 * Desc 首页数据
 * @author HUI
 */
class HomeService extends ApiBaseService {

    /**
     * 删除
     * @param array $params 参数 
     * * */
    public static function getData() {
        $data['statistics'] = self::getDataStatistics();
        $data['line'] = self::getLine();
        $data['bar'] = self::getLine();
        $data['pie'] = self::getLine();
        $data['scatter'] = self::getScatter();
        $data['bar_b'] = self::getLine();
        $data['pie_b'] = self::getLine();
        return self::jsonSuccess($data);
    }

    /**
     * 首页数据汇总
     * * */
    private static function getDataStatistics() {
        $data = [
            'pv' => [
                'name' => '访问次数',
                'count' => 1000000,
            ],
            'uv' => [
                'name' => '访问人数',
                'count' => 50000,
            ],
            'user' => [
                'name' => '所有用户',
                'count' => 10000,
            ],
            'new' => [
                'name' => '新增用户',
                'count' => 100,
            ],
        ];
        return $data;
    }

    /**
     * 折线
     * * */
    private static function getLine() {
        $data['category'] = ['07-27', '07-28', '07-29', '07-30', '07-31', '08-01', '08-02'];
        $data['line'] = [150, 230, 224, 218, 135, 147, 260];
        return $data;
    }

    /**
     * 柱状
     * * */
    private static function getBar() {
        $data['category'] = ['07-27', '07-28', '07-29', '07-30', '07-31', '08-01', '08-02'];
        $data['line'] = [150, 230, 224, 218, 135, 147, 260];
        return $data;
    }

    /**
     * 饼图
     * * */
    private static function getPie() {
        $data = [
            ['name' => '订单金额', 'value' => 1048],
            ['name' => '订单数量', 'value' => 500],
            ['name' => '退款金额', 'value' => 348],
            ['name' => '退款数量', 'value' => 10],
            ['name' => '待退款数', 'value' => 10],
        ];
        return $data;
    }

    /**
     * 散点图
     * * */
    private static function getScatter() {
        $data = [
            [10.0, 8.04],
            [8.07, 6.95],
            [13.0, 7.58],
            [9.05, 8.81],
            [11.0, 8.33],
            [14.0, 7.66],
            [13.4, 6.81],
            [10.0, 6.33],
            [14.0, 8.96],
            [12.5, 6.82],
            [9.15, 7.2],
            [11.5, 7.2],
            [3.03, 4.23],
            [12.2, 7.83],
            [2.02, 4.47],
            [1.05, 3.33],
            [4.05, 4.96],
            [6.03, 7.24],
            [12.0, 6.26],
            [12.0, 8.84],
            [7.08, 5.82],
            [5.02, 5.68]
        ];
        return $data;
    }

}
